//
//  GoodsTableViewCell.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/9/11.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "GoodsTableViewCell.h"

@interface GoodsTableViewCell ()

@property (nonatomic, strong) UIImageView *iv;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *priceLabel;
@property (nonatomic, strong) UIImageView *collectImg;

@property (nonatomic, strong) UILabel *reminderLabel;
@property (nonatomic, strong) UILabel *nunmberLabel;
@end
@implementation GoodsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        _iv = [UIImageView new];
        [self addSubview:_iv];
        [_iv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(10);
            make.left.equalTo(self).offset(10);
            make.width.equalTo(@86);
            make.height.equalTo(@86);
        }];
        
        _reminderLabel = [UILabel new];
        _reminderLabel.text = @"已失效";
        _reminderLabel.textColor = ColorFrom16(0xffffff);
        _reminderLabel.font = PFRFONT(12);
        _reminderLabel.textAlignment = 1;
        _reminderLabel.backgroundColor = ColorFrom16A(0x323232, 0.68);
        [_iv addSubview:_reminderLabel];
        [_reminderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(_iv);
            make.left.and.right.equalTo(_iv);
            make.height.equalTo(@19.1);
        }];
        
        _titleLabel = [UILabel new];
        _titleLabel.text = @"爱儿美儿童摄影秋季梦想儿童摄影秋季梦想秋季梦想";
        _titleLabel.textColor = ColorFrom16(0x323232);
        _titleLabel.font = PFRFONT(14);
        _titleLabel.numberOfLines = 2;
        [self addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(7);
            make.left.equalTo(_iv.mas_right).offset(10);
            make.right.equalTo(self).offset(-37);
            make.height.equalTo(@40);
        }];
        
        _priceLabel = [UILabel new];
        _priceLabel.text = @"￥580";
        _priceLabel.textColor = ColorFrom16(0xFF5B7A);
        _priceLabel.font = PFMFONT(18);
        [self addSubview:_priceLabel];
        [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(10);
            make.left.equalTo(_iv.mas_right).offset(10);
            make.width.greaterThanOrEqualTo(@47);
            make.height.equalTo(@25);
        }];
        
        _nunmberLabel = [UILabel new];
        _nunmberLabel.text = @"收藏时间";
        _nunmberLabel.textColor = ColorFrom16(0x999999);
        _nunmberLabel.font = PFRFONT(14);
        [self addSubview:_nunmberLabel];
        [_nunmberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(-24);
            make.right.equalTo(self).offset(-10);
            make.width.greaterThanOrEqualTo(@19);
            make.height.equalTo(@20);
        }];
    }
    return self;
}

- (void)configViewWithModel:(CollectionGoodsModel *)model
{
    [_iv sd_setImageWithURL:[NSURL URLWithString:STRING(model.goods_img)] placeholderImage:nil];
    _titleLabel.text = model.goods_name;
    _priceLabel.text = model.sale_price;
    _nunmberLabel.text = model.ctime;
    _reminderLabel.text = model.show_status_value;
    if([GW_Tool isEmptyString:model.show_status_value])
    {//如果已失效
        _priceLabel.textColor = ColorFrom16(0xFF5B7A);
        _reminderLabel.backgroundColor = ColorClear;
    }
    else
    {
        _priceLabel.textColor = ColorFrom16(0xA4A4A4);
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
